#! /usr/bin/env sh  
MAIN_MODULE=main.py  
`ulimit -n 65535`   
case $1 in  
    start)  
        PYTHONPATH=.:$PYTHONPATH twistd -y $MAIN_MODULE &
        ;;  
    stop)  
        kill `cat twistd.pid`  
        ;;  
    restart)  
        kill `cat twistd.pid`  
        sleep 1  
        PYTHONPATH=.:$PYTHONPATH twistd -y $MAIN_MODULE  
        ;;  
    log)  
        tail -f twistd.log  
        ;;  
    *)  
        echo "Usage: ./ctlapp.sh start | stop | restart | log"  
        ;;  
esac  
